﻿using System.Collections.Generic;
using System.Linq;
using System.Reflection;

public static class CustomAttributeProviderExtendtions
{
    public static T GetCustomAttribute<T>(this ICustomAttributeProvider obj) where T : System.Attribute
    {
        return obj.GetCustomAttributes(typeof(T), true).OfType<T>().FirstOrDefault();
    }
    public static IEnumerable<T> GetCustomAttributes<T>(this ICustomAttributeProvider obj) where T : System.Attribute
    {
        return obj.GetCustomAttributes(true).Where(p => p.GetType().IsSubclassOf(typeof(T))).Cast<T>();
    }
}
